<template>
  <div>
    <iframe
      v-if="flag"
      width="100%"
      style="border: none"
      :height="`${height}px`"
      :src="url"
    />
  </div>
</template>
<script>
import axios from 'axios'
import { encryption } from '@/aesEncrypt'
export default {
  data() {
    return {
      flag: true,
      height: window.innerHeight - 140,
      REPORT_URL: '',
      token_temp: '',
      url: ''
    }
  },
  mounted() {},
  created() {
    this.$data.REPORT_URL = process.env.VUE_APP_REPORT_FORM
    this.loginNoPass()
  },
  methods: {
    // 免密登录
    loginNoPass() {
      setTimeout(() => {
        console.log('时间' + new Date().getTime())
        const param = encryption(`admin,${new Date().getTime()}`)
        const param1 = encryption(`admin,1755067355871`)
        console.log('加密后的参数:' + param)
        console.log('加密后的参数:' + param1)
        const loginParams = {
          username: decodeURIComponent(param1),
          sysType: 'lms',
          checkKey: Date.now(),
          defaultSystem: 'lms'
        }
        axios.post('https://gwuat.bsdits.cn/common/sys/userLogin/PasswordFreeLogin', loginParams, {
          headers: {
            'Content-Type': 'application/json'
          }
        }).then(res => {
          console.log('qqqqqqqq', res)
          this.token_temp = res.data.result.token
          const reportUrl = this.$data.REPORT_URL + '/view/report?viewlet=xspHr/招聘模块使用报表情况.cpt'
          console.log('报表原地址')
          console.log(reportUrl)
          this.url = this.$data.REPORT_URL + '/ssologin?redirect=' + encodeURIComponent(reportUrl) + '&token=' + this.token_temp
          console.log('集成sso后的新地址')
          console.log(this.url)
          this.flag = true
        })
      }, 500)
    }
  }
}
</script>
